package com.teyao.teyao_back.controller;

import com.teyao.teyao_back.config.CaptchaUtils;
import com.teyao.teyao_back.config.CaptureConfig;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@CrossOrigin
@RestController
@RequestMapping
@Slf4j
public class CaptureController {
    @GetMapping("/getCaptcha")
    public void getCaptcha(String uuid, HttpServletResponse response) throws IOException {
        log.info("INFO ----------------------- UUID: "+ uuid);
        CaptchaUtils.getCircleCaptcha(uuid, response);
    }

    /**
     * 模拟登录校验
     */
    @GetMapping("/login")
    public boolean login(String uuid, String code) {
        return CaptchaUtils.verify(uuid, code);
    }
}
